<?php

require_once "genie_pdo.php";

$dbh = genie_connect();
	  
$stmt = "SELECT album, sum(play_count) as 'total' "
	  . "FROM songs "
	  . "WHERE artist = '".$_GET['artist']."' "
	  . "GROUP BY album "
	  . "ORDER BY total DESC";

$sth = $dbh->query($stmt);

$return = "<Albums>";
while ($row = $sth->fetch (PDO::FETCH_OBJ))
{
	$return .= "<Album><Name>".$row->album."</Name><Total>".$row->total."</Total></Album>";
}
$return .= "</Albums>";
	
print ($return);
	
$dbh = NULL;  # close connection

?>
